package com.eveno.demo.android.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.WindowManager;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.eveno.demo.android.R;
import com.eveno.demo.android.route.PageRouter;

import java.util.HashMap;
import java.util.Map;

public class SplashActivity extends AppCompatActivity {


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate( savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//隐藏状态栏
        getSupportActionBar().hide();//隐藏标题栏
        setContentView(R.layout.activity_splash);
        Thread myThread=new Thread(){//创建子线程
            @Override
            public void run() {
                try{
                    sleep(5000);//使程序休眠五秒
//                    Intent it=new Intent(getApplicationContext(),MainActivity.class);//启动MainActivity
//                    startActivity(it);
                    startApp();
                    finish();//关闭当前活动
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        };
        myThread.start();//启动线程
    }

    private void startApp(){
        Map params = new HashMap();
        params.put("test1","v_test1");
        params.put("test2","v_test2");
        PageRouter.openPageByUrl(this, PageRouter.FLUTTER_PAGE_URL, params);
    }
}
